

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Command Line Tool - mod_python &mdash; Mod_python v3.4.1-3.4.1 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '3.4.1-3.4.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/sidebar.js"></script>
    <link rel="author" title="About these documents" href="about.html" />
    <link rel="copyright" title="Copyright" href="copyright.html" />
    <link rel="top" title="Mod_python v3.4.1-3.4.1 documentation" href="index.html" />
    <link rel="next" title="Server Side Includes" href="ssi.html" />
    <link rel="prev" title="Standard Handlers" href="handlers.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="ssi.html" title="Server Side Includes"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="handlers.html" title="Standard Handlers"
             accesskey="P">previous</a> |</li>
        <li><a href="contents.html">Mod_python v3.4.1-3.4.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="command-line-tool-mod-python">
<span id="cmd"></span><h1>Command Line Tool - mod_python<a class="headerlink" href="#command-line-tool-mod-python" title="Permalink to this headline">¶</a></h1>
<div class="section" id="overview-of-mod-python-command">
<span id="cmd-overview"></span><h2>Overview of mod_python command<a class="headerlink" href="#overview-of-mod-python-command" title="Permalink to this headline">¶</a></h2>
<p>mod_python includes a command-line tool named <tt class="docutils literal"><span class="pre">mod_python</span></tt>. The
<tt class="docutils literal"><span class="pre">mod_python</span></tt> command exists to facilitate tasks related to
configuration and management of mod_python.</p>
<p>The general syntax for the command is <tt class="docutils literal"><span class="pre">mod_python</span> <span class="pre">&lt;subcommand&gt;</span> <span class="pre">&lt;arguments&gt;</span></tt>
where <tt class="docutils literal"><span class="pre">&lt;subcommand&gt;</span></tt> is a separate tool with its own argument requirements.</p>
</div>
<div class="section" id="mod-python-command-line-tool-sub-commands">
<span id="cmd-subcommands"></span><h2>mod_python command line tool sub-commands<a class="headerlink" href="#mod-python-command-line-tool-sub-commands" title="Permalink to this headline">¶</a></h2>
<div class="section" id="create">
<h3>create<a class="headerlink" href="#create" title="Permalink to this headline">¶</a></h3>
<p><tt class="docutils literal"><span class="pre">create</span></tt> sub-command creates a simple Apache configuration and a
skeleton directory structure necessary for placement of configuration,
logs and content. It is meant to be executed only once per lifetime of
a project.</p>
<p>The configuration generated by <tt class="docutils literal"><span class="pre">create</span></tt> consists of an
<a class="reference internal" href="pythonapi.html#module-httpdconf" title="httpdconf: HTTPd Configuration"><tt class="xref py py-mod docutils literal"><span class="pre">httpdconf</span></tt></a> based version (in Python) which can then be used to
generate an actual Apache configuration (by using the <tt class="docutils literal"><span class="pre">genconfig</span></tt>
subcommand or simply executing the config files itself). The idea is
that the Apache configuration is always generated and the Python
version is the one meant for editing/adjustments.</p>
<p>The <tt class="docutils literal"><span class="pre">create</span></tt> subcommand will create the necessary files and
directories if they do not exist, but will not overwrite any existing
files or directories only producing a warning when a file or directory
already exists. It will abort if the Python version of the
configuration file already exists.</p>
<p><tt class="docutils literal"><span class="pre">create</span></tt> requires a single argument: the distination directory,
Apache <tt class="docutils literal"><span class="pre">ServerRoot</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">create</span></tt> has the following command options:</p>
<dl class="cmdoption">
<dt id="cmdoption--listen">
<tt class="descname">--listen</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption--listen" title="Permalink to this definition">¶</a></dt>
<dd><p>A string describing the port and optional IP address on which the
server is to listen for incoming requests in the form
<tt class="docutils literal"><span class="pre">[ip_address:]port</span></tt> The argument will be applied to the Apache
<tt class="docutils literal"><span class="pre">Listen</span></tt> directive as is and therefore must be syntactically
compatible with it.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption--pythonpath">
<tt class="descname">--pythonpath</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption--pythonpath" title="Permalink to this definition">¶</a></dt>
<dd><p>A colon (<tt class="docutils literal"><span class="pre">&quot;:&quot;</span></tt>) separate list of paths to be applied to the
<a class="reference internal" href="directives.html#dir-other-pp"><em>PythonPath</em></a> directive.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption--pythonhandler">
<tt class="descname">--pythonhandler</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption--pythonhandler" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the Python handler to use. Applied to the
<a class="reference internal" href="directives.html#dir-handlers-ph"><em>PythonHandler</em></a> directive.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption--pythonoption">
<tt class="descname">--pythonoption</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption--pythonoption" title="Permalink to this definition">¶</a></dt>
<dd><p>An option to be specified in the configuration. Multiple options
are alowed. Applied to the <a class="reference internal" href="directives.html#dir-other-po"><em>PythonOption</em></a> directive.</p>
</dd></dl>

</div>
<div class="section" id="genconfig">
<span id="cmd-sub-create-example"></span><h3>genconfig<a class="headerlink" href="#genconfig" title="Permalink to this headline">¶</a></h3>
<p>This sub-command exists to facilitate re-generation of an Apache
configuration from a Python-based one. All it does is run the script,
but its use is recommended because the mod_python command will execute
the correct version of Python under which mod_python was initially
compiled. Example:</p>
<div class="highlight-python"><pre>mod_python genconfig /path/to/server_root/httpd_conf.py &gt; /path/to/server_root/httpd.conf</pre>
</div>
</div>
<div class="section" id="start">
<h3>start<a class="headerlink" href="#start" title="Permalink to this headline">¶</a></h3>
<p>Starts an Apache instance. Requires a single argument, the path to
Apache configuration file.</p>
</div>
<div class="section" id="stop">
<h3>stop<a class="headerlink" href="#stop" title="Permalink to this headline">¶</a></h3>
<p>Stops an Apache instance (using graceful-stop). Requires a single
argument, the path to Apache configuration file.</p>
</div>
<div class="section" id="restart">
<h3>restart<a class="headerlink" href="#restart" title="Permalink to this headline">¶</a></h3>
<p>Stops an Apache instance (using graceful). Requires a single argument,
the path to Apache configuration file.</p>
</div>
<div class="section" id="version">
<h3>version<a class="headerlink" href="#version" title="Permalink to this headline">¶</a></h3>
<p>This sub-command prints out version and location information about
this mod_python installation, the Apache HTTP Server and Python used
when building this mod_python instance.</p>
</div>
<div class="section" id="example">
<h3>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h3>
<p>To create an Apache instance with all the required directories for a
WSGI application which is located in <tt class="docutils literal"><span class="pre">/path/to/myapp</span></tt> and defined in
<tt class="docutils literal"><span class="pre">/path/to/myapp/myapp/myapp/wsgi.py</span></tt>, run the following:</p>
<div class="highlight-python"><pre>mod_python create /path/to/new/server_root \
    --pythonpath=/path/to/my/app \
    --pythonhandler=mod_python.wsgi \
    --pythonoption="mod_python.wsgi.application myapp.wsgi::application"</pre>
</div>
<p>The above example will create a Python-based configuration in
<tt class="docutils literal"><span class="pre">/path/to/new/server_root/conf/http_conf.py</span></tt> which is a simple
Pythong script. When executed, the output of the script becomes an
Apache configuration (<tt class="docutils literal"><span class="pre">create</span></tt> will take care of generating the
first Apache config for you).</p>
<p>You should be able to run this Apache instance by executing:</p>
<div class="highlight-python"><pre>mod_python start /path/to/new/server_root/conf/httpd.conf</pre>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Command Line Tool - mod_python</a><ul>
<li><a class="reference internal" href="#overview-of-mod-python-command">Overview of mod_python command</a></li>
<li><a class="reference internal" href="#mod-python-command-line-tool-sub-commands">mod_python command line tool sub-commands</a><ul>
<li><a class="reference internal" href="#create">create</a></li>
<li><a class="reference internal" href="#genconfig">genconfig</a></li>
<li><a class="reference internal" href="#start">start</a></li>
<li><a class="reference internal" href="#stop">stop</a></li>
<li><a class="reference internal" href="#restart">restart</a></li>
<li><a class="reference internal" href="#version">version</a></li>
<li><a class="reference internal" href="#example">Example</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="handlers.html"
                        title="previous chapter">Standard Handlers</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="ssi.html"
                        title="next chapter">Server Side Includes</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/commandline.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="ssi.html" title="Server Side Includes"
             >next</a> |</li>
        <li class="right" >
          <a href="handlers.html" title="Standard Handlers"
             >previous</a> |</li>
        <li><a href="contents.html">Mod_python v3.4.1-3.4.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; <a href="copyright.html">Copyright</a> 1990-2013, Apache Software Foundation, Gregory Trubetskoy.
      Last updated on Oct 22, 2013.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>
  </body>
</html>